import java.util.*;
import java.io.*;
import java.util.HashSet;
import java.util.Scanner;
public class zy2 {

    public static void main(String[] args) {
        try {
            Scanner sc=new Scanner(System.in);
            System.out.println("n为:");
            int n=sc.nextInt();
            FileWriter fileWriter = new FileWriter("data4.txt");
            for (int i = 1; i <= n; i++) {
                if(i%3 == 0 && i%5 == 0){
                    System.out.println("'FizzBuzz'");
                    fileWriter.write("'FizzBuzz'"+"\n");
                }else if(i%5 == 0){
                    System.out.println("'Buzz'");
                    fileWriter.write("'Buzz'"+"\n");
                }else if(i%3 == 0 ){
                    System.out.println("'Fizz'");
                    fileWriter.write("'Fuzz'"+"\n");
                }else{
                    System.out.println(i);
                    fileWriter.write(i+"\n");
                }

            }
            fileWriter.close();
        }
        catch (Exception e){

        }
    }


    public static void main3(String[] args) {
        //键盘输入一个字符串，输出字符串中只出现2次的最后一个字符.
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一串字符:");
        String s = scanner.nextLine();
        int count = 0;
        char[] ss = s.toCharArray();
        for (int i = s.length()-1; i >0 ; i--) {
            for (int j = 0; j < i; j++) {
                if(ss[i] ==ss[j]){
                    count++;

                }
            }
            if(count==1){
                System.out.println(ss[i]);
                try {
                    FileWriter fileWriter = new FileWriter("data3.txt");
                    fileWriter.write(ss[i]);
                    fileWriter.close();
                }catch (Exception e){
                }
                break;
            }
        }
    }

    public static int MaxLength(String s) {
        //containsKey判断集合中是否存在某个值
        //charAt返回对应下标的字符
        //Math.max()，比较的是两个同一类型数据的大小，取较大的值返回
        HashMap<Character,Integer> map = new HashMap<>();
        int left=0;
        int max=0;
        for (int i = 0; i < s.length(); i++) {
            if(map.containsKey(s.charAt(i))){
                left=Math.max(left,map.get(s.charAt(i))+1);
            }
            map.put(s.charAt(i),i);
            max=Math.max(max,i-left+1);
        }
        return max;
    }

    public static void main2(String[] args) {
        //输入一个字符串,输出无重复字符的一个最长子字符串长度。
        try {
            FileWriter js=new FileWriter("data2.txt");
            System.out.println("请输入字符串:");
            Scanner in = new Scanner(System.in);
            String str = in.nextLine();
            js.write("请输入字符串:" + str+"\r\n");
            System.out.println("输入的字符不重复最大个数：" + MaxLength(str)+"\r\n");
            js.write("输入的字符不重复最大个数：" + MaxLength(str)+"\r\n");
            js.close();
        }
        catch(Exception ex){
        }
    }

    public static void main1(String[] args) {
        //产生10个三位整数，输出最大值，最小值，平均值
        Random random=new Random();
        int[] a=new int[10];
        int sum=0;
        int max=a[0];
        System.out.println("随机产生的10个三位整数为:");
        for (int i = 0; i < a.length; i++) {
            a[i]= random.nextInt(900)+100;
            sum+=a[i];
            System.out.println(a[i]);
        }
        for (int j = 0; j < a.length; j++) {
            if(a[j]>max)
                max=a[j];
        }
        int min=a[0];
        for (int z = 0; z <a.length ; z++) {
            if(a[z]<min)
                min=a[z];
        }
        System.out.println("最大值为:"+max);
        System.out.println("最小值为:"+min);
        System.out.println("平均值为:"+sum/a.length);
        try {
            FileWriter js=new FileWriter("data1.txt");
            js.write("最大值为:"+max+"\r\n");
            js.write("最小值为:"+min+"\r\n");
            js.write("平均值为:"+sum/a.length+"\r\n");
            js.close();
        }
        catch(Exception ex){
        }
    }
}
